<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>第一个</title>

</head>
<style>
    .box .focus {
        background-color: #8fbff5;
    }
</style>

<body>
    <div class="box">
        <input type="text"><br />
        <input type="text">
    </div>
</body>

<script>
    window.onload = function () {
        var oInput = document.getElementsByTagName("input");
        for (var i = 0; i < oInput.length - 1; i++) {


            oInput[i].onfocus = function () {
                this.className = "focus";
            }
            oInput[i].onblur = function () {
                this.className = "";
            }
        }
    }
</script>

</html>